import Cookies from 'js-cookie'

// 存储用户token
const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// 存储用户uid
const UidKey = 'User-Uid'

export function getUid() {
  return Cookies.get(UidKey)
}

export function setUid(uid) {
  return Cookies.set(UidKey, uid)
}

export function removeUid() {
  return Cookies.remove(UidKey)
}

// 存储用户type
const TypeKey = 'User-type'

export function getType() {
  return Cookies.get(TypeKey)
}

export function setType(type) {
  return Cookies.set(TypeKey, type)
}

export function removeType() {
  return Cookies.remove(TypeKey)
}

// 存储特定值
export function getValue(key) {
  return Cookies.get(key)
}

export function setValue(key, val) {
  let time = new Date(new Date().getTime() + 30 * 360 * 24000);
  return Cookies.set(key, val, { expires: time })
}

export function removeValue(key) {
  return Cookies.remove(key)
}
